package com.ye.study.config;


import com.ye.study.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther zzyy
 * @create 2025-03-11 16:43
 */
@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig  //RedisConfig   LLMConfig
{

   /* @Bean
    public ChatLanguageModel chatLanguageModel()
    {
        return
            OpenAiChatModel.builder()
                    .apiKey(System.getenv("aliQwen-api"))
                    .modelName("qwen-plus-latest")
                    .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
            .build();
    }*/


    /**
    * @Description: 出于与 OpenAI 兼容考虑，您也可以将 base_url 设置为 https://api.deepseek.com/v1 来使用，
     * 但注意，此处 v1 与模型版本无关。
    * @Auther: zzyybs@126.com
    */
    @Bean  //  https://platform.deepseek.com/usage
    public ChatLanguageModel chatLanguageModel()
    {
        return
                OpenAiChatModel.builder()
                        .apiKey(System.getenv("deepseek-api"))
                        .modelName("deepseek-chat")
                        //.modelName("deepseek-reasoner")
                        .baseUrl("https://api.deepseek.com/v1")
                .build();
    }



    /**我们自定义的业务接口，yong aiservice完成了impl实现类编写
     public interface ChatAssistant
     {
         String chat(String prompt);
     }
    */
    // 你使用第2种类，高阶API    AiService
   @Bean
    public ChatAssistant chatAssistant(ChatLanguageModel chatLanguageModel)
    {
        return AiServices.create(ChatAssistant.class, chatLanguageModel);
    }
}

